//
// Created by luosong on 15/8/28.
// Copyright (c) 2015 CHANJET. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CSPNetworking.h"

@class CSPIdentityExtra;

FOUNDATION_EXPORT NSString *const CSPIdentityErrorDomain;

typedef NS_ENUM(NSInteger, CSPIdentityErrorType) {
    CSPIdentityErrorUnknown,
    CSPIdentityErrorIncompleteSignature,
    CSPIdentityErrorInvalidClientTokenId,
    CSPIdentityErrorMissingAuthenticationToken,
    CSPIdentityErrorDeveloperUserAlreadyRegistered,
    CSPIdentityErrorExternalService,
    CSPIdentityErrorInternalError,
    CSPIdentityErrorInvalidIdentityPoolConfiguration,
    CSPIdentityErrorInvalidParameter,
    CSPIdentityErrorLimitExceeded,
    CSPIdentityErrorNotAuthorized,
    CSPIdentityErrorResourceConflict,
    CSPIdentityErrorResourceNotFound,
    CSPIdentityErrorTooManyRequests,
    CSPIdentitySignupAccountExists, /** 申请注册的账号已经存在 */

};

#pragma mark - IdentityGetCredentials

/**
*   使用账号和密码登录CIA系统
*/
@interface CSPIdentityLoginWithAccountRequest : CSPRequest

/**
<p>A unique identifier in the format REGION:GUID.</p>
*/
@property (nonatomic, strong) NSString *identityId;

/**
<p>登录的用户账户名称
*/
@property (nonatomic, strong) NSString *account;

/**
<p>登录的用户账户密码，经过 MD5 转换后的
*/
@property (nonatomic, strong) NSString *password;

@property (nonatomic, strong) NSString *needInviteList;

@property (nonatomic, strong) NSString *endpoint_id;

@property (nonatomic, strong) NSString *coop;

/**
<p>A set of optional name-value pairs that map provider names to provider tokens.</p>
*/
@property (nonatomic, strong) NSDictionary *logins;

@end

@interface CSPIdentityGetCredentialsResponse : CSPRequest

/**
<p> CIA 分配的用户ID
*/
@property (nonatomic, strong) NSString *userId;

/**
<p> 用户登录的企业 ID
*/
@property (nonatomic, strong) NSString *orgId;

/**
<p> 用户账号
*/
@property (nonatomic, strong) NSString *account;

/**
<p> 用户姓名
*/
@property (nonatomic, strong) NSString *name;

/**
<p> 授权可以访问的 Token
*/
@property (nonatomic, strong) NSString *accessToken;

/**
<p> 刷新令牌的 Token
*/
@property (nonatomic, strong) NSString *refreshToken;
/**
<p> 离刷新令牌的 Token 的失效时长（秒)
*/
@property (nonatomic, assign) NSTimeInterval expiration;

@property (nonatomic, strong) CSPIdentityExtra * extra;

@end


#pragma mark - 刷新 sessionToken 请求
@interface CSPIdentityRefreshTokenRequest : CSPRequest

@property (nonatomic, strong) NSString *refreshToken;

@end

#pragma mark - 退出账号请求
@interface CSPIdentitySignoutRequest : CSPRequest

@property (nonatomic, strong) NSString *accessToken;
@property (nonatomic, strong) NSString *clientId;
@property (nonatomic, strong) NSString *redirectUri;

@end

#pragma mark - CSPIdentityApplySignupCodeRequest
typedef NS_ENUM(NSInteger, CSPIdentityAccountType) {
    CSPIdentityAccountMobile,
    CSPIdentityAccountEmail,
};

@interface CSPIdentityApplySignupCodeRequest: CSPRequest

@property (nonatomic, assign) CSPIdentityAccountType accountType;
@property (nonatomic, strong) NSString *account;

@end

#pragma mark - CSPIdentityApplySignupCodeResponse

@interface CSPIdentityApplySignupCodeResponse: CSPRequest
/**
* true：申请注册的手机号或者邮箱已经在 CSP 平台注册过。
*/
@property (nonatomic, assign) BOOL exist;
@property (nonatomic, assign) NSInteger errorCode;
@end

#pragma mark -CSPIdentitySignupRequest

/**
* 申请注册账号
*/
@interface CSPIdentitySignupRequest : CSPRequest
@property (nonatomic, strong) NSString *account;
@property (nonatomic, strong) NSString *verfyCode;
@end
